package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.entity.DXFShape;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:52
 */
public class DXFShapeHandler extends AbstractEntityHandler {
    public static final int GROUPCODE_NAME = 2;
    public static final int GROUPCODE_SIZE = 40;
    public static final int GROUPCODE_SCALE_X = 41;
    public static final int GROUPCODE_OBLIQUE_ANGLE = 51;
    protected DXFShape shape;

    public DXFShapeHandler() {
    }

    @Override
    public String getDXFEntityName() {
        return "SHAPE";
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.shape;
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 2:
                this.shape.setName(var2.getValue());
                break;
            case 10:
                this.shape.getInsertPoint().setX(var2.getDoubleValue());
                break;
            case 20:
                this.shape.getInsertPoint().setY(var2.getDoubleValue());
                break;
            case 30:
                this.shape.getInsertPoint().setZ(var2.getDoubleValue());
                break;
            case 40:
                this.shape.setHeight(var2.getDoubleValue());
                break;
            case 50:
                this.shape.setRotation(var2.getDoubleValue());
                break;
            case 51:
                this.shape.setObliqueAngle(var2.getDoubleValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.shape);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.shape);
    }

    @Override
    public void startDXFEntity() {
        this.shape = new DXFShape();
    }
}

